package com.augurit.wf.common.tag.datetime;

import java.io.Writer;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.augurit.wf.common.tag.base.WfPageElemWithPrivImpl;
import com.opensymphony.xwork2.util.ValueStack;

import de.odysseus.el.tree.Tree;


public class WfDateTime extends  WfPageElemWithPrivImpl{
	
	private String name;
	private String type;
	private String value;
	private String readOnly;
	private String cssClass;
	private String disabled;	//是否锁定
	private String hidden;		//是否隐藏
	
	
	private String debug; //调试，显示当前权限
	private String onblur;
	private String onfocus;
	private String width;
	private String align;
	private String style;
	private String size;
	private String height;
	private String onclick;
	
	public WfDateTime(ValueStack stack){
		super(stack); 
	}
	
	@Override
	public boolean start(Writer arg0) {
		boolean result = super.start(arg0);
		try {
			 StringBuilder str = new StringBuilder();
			 //如果没有被权限隐藏
			 if(!this.isHiddenByPriv()){
				
				str.append("<input ");
				if (name != null) {
					str.append(" name=\"" + name + "\"");
				}
				if( name != null){
					str.append(" type=\"" + type + "\"");
				}
				if (this.getId() != null) {
					str.append(" id=\"" + this.getId() + "\"");
				}
				
				
				//如果没有被权限锁定
				if(this.isDisabledByPriv()){
	                str.append(" readonly");
	            }
				
				if( cssClass != null){
					str.append(" class=\"" + cssClass + "\"");
				}
				if (value != null) {
					str.append(" value=\"" + value + "\"");
				}
				if (height != null) {
					str.append(" height=\"" + height + "\"");
				}
				if (onblur != null) {
					str.append(" onblur=\"" + onblur + "\"");
				}
				if (width != null) {
					str.append(" width=\"" + width + "\"");
				}
				if (align != null) {
					str.append(" align=\"" + align + "\"");
				}
				if (style != null) {
					str.append(" style=\"" + style + "\"");
				}
				if (size != null) {
					str.append(" size=\"" + size + "\"");
				}
				if(onclick != null)
					str.append(" onclick=\"" + onclick + "\"");
				if(onfocus != null){
					str.append(" onfocus=\"" + onfocus + "\"");
				}
				str.append("/>");
			 }
				
			if(name.equals("receivedDate"))System.out.println(str.toString());	
			arg0.write(str.toString());
		} catch (Exception e) {
			Logger.getLogger(Tree.class.getName()).log(Level.WARN, null, e);
		}
		return result;
	}

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	public String getValue() {
		return value;
	}


	public void setValue(String value) {
		this.value = value;
	}


	public String getReadOnly() {
		return readOnly;
	}


	public void setReadOnly(String readOnly) {
		this.readOnly = readOnly;
	}


	public String getCssClass() {
		return cssClass;
	}


	public void setCssClass(String cssClass) {
		this.cssClass = cssClass;
	}


	public String getDisabled() {
		return disabled;
	}


	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}


	public String getHidden() {
		return hidden;
	}


	public void setHidden(String hidden) {
		this.hidden = hidden;
	}


	public String getDebug() {
		return debug;
	}


	public void setDebug(String debug) {
		this.debug = debug;
	}


	public String getOnblur() {
		return onblur;
	}


	public void setOnblur(String onblur) {
		this.onblur = onblur;
	}


	public String getOnfocus() {
		return onfocus;
	}


	public void setOnfocus(String onfocus) {
		this.onfocus = onfocus;
	}


	public String getWidth() {
		return width;
	}


	public void setWidth(String width) {
		this.width = width;
	}


	public String getAlign() {
		return align;
	}


	public void setAlign(String align) {
		this.align = align;
	}


	public String getStyle() {
		return style;
	}


	public void setStyle(String style) {
		this.style = style;
	}


	public String getSize() {
		return size;
	}


	public void setSize(String size) {
		this.size = size;
	}


	public String getHeight() {
		return height;
	}


	public void setHeight(String height) {
		this.height = height;
	}

	public String getOnclick() {
		return onclick;
	}

	public void setOnclick(String onclick) {
		this.onclick = onclick;
	}
	
	
	
}
